class Solution {
public:
    int divisorSubstrings(int num, int k) {
        int s = 0;
        int ret = 0;
        int t = 1;
        for(int i = 1;i <k;i++) t*= 10;
        for(long long tmp = 1; tmp <= num;tmp *= 10)
        {
            s/= 10;
            s += num / tmp % 10 *t;
            if(tmp>= t && s != 0 && num%s == 0)
                ret++;
        }
        return ret;
    }
};
class Solution {
public:
    int minimumDifference(vector<int>& nums, int k) {
        
        sort(nums.begin(),nums.end());
        int ret = 1000000;
        for(int i = 0;i + k <= nums.size();i++){
            ret = min(ret,nums[i + k - 1] - nums[i]);
        }
        return ret;
    }
}
